/*
 * @Author: fah 1742484532@qq.com
 * @Date: 2024-09-13 10:57:59
 * @LastEditors: fah 1742484532@qq.com
 * @LastEditTime: 2024-09-13 14:38:54
 * @FilePath: \livetree-admin-server\src\interceptor\http-res.interceptor.ts
 * @Description: 指飞部-企业数字化管理系统
 * @version: 1.0
 */
import { CallHandler, ExecutionContext, NestInterceptor } from '@nestjs/common';
import { map } from 'rxjs';
import { responseMessage } from 'src/utils';

export class HttpResTransformInterceptor implements NestInterceptor {
  intercept(context: ExecutionContext, next: CallHandler) {
    console.log('Before...');
    return next.handle().pipe(
      map(({ data, msg, code }) => {
        console.log('After', data, code, msg);
        return responseMessage(data, msg, code);
      }),
    );
  }
}
